package lesson

import "fmt"

func Lesson06() {
	fmt.Println("package lesson file lesson/lesson06.go function Lesson06")

	var array1 [2]int
	var array2 [1]int
	//cannot use array1 (type [2]int) as type [1]int in assignment
	//array2 = array1
	fmt.Println("[array1]:", array1)
	fmt.Println("[array2]:", array2)

	var array3 [3]string
	fmt.Println("[array3]:", array3)

	var array4 [20]int = [20]int{1, 2, 3}
	fmt.Println("[array4]:", array4)
	array5 := [...]int{1, 2, 3}
	fmt.Println("[array5]:", array5)
	var array6 [20]int = [20]int{10: 1, 11: 2, 12: 3}
	fmt.Println("[array6]:", array6)
	array7 := [...]int{19: 1}
	fmt.Println("[array7]:", array7)

	var point_array *[20]int = &array7
	fmt.Println("[point_array]:", point_array)

	x, y := 1, 2
	array8 := [...]*int{&x, &y}
	fmt.Println("[array8]:", array8)

	array9 := [2]int{1, 2}
	array10 := [2]int{1, 2}
	fmt.Println("[array9 == array10]:", array9 == array10)
	fmt.Println("[array9 == array1]:", array9 == array1)
	//mismatched types [2]int and [3]string
	//fmt.Println("[array9 == array3]:", array9 == array3)

	point_array2 := new([10]int)
	point_array2[1] = 2
	fmt.Println("[point_array2]:", point_array2)

	array11 := [2][3]int{
		{1, 1, 1}, {2, 2, 2}}
	fmt.Println("[array11]:", array11)
	array12 := [2][3]int{
		{1, 1}, {2, 2}}
	fmt.Println("[array12]:", array12)

	// 冒泡排序
	array0 := [...]int{5, 2, 6, 3, 9}
	fmt.Println("[array0]:", array0)

	num := len(array0)
	for i := 0; i < num; i++ {

		for j := i + 1; j < num; j++ {
			if array0[i] > array0[j] {
				temp := array0[i]
				array0[i] = array0[j]
				array0[j] = temp
			}
		}
	}
	fmt.Println("[array0]:", array0)

	for i := 0; i < 3; i++ {
		value := 1
		fmt.Println("[&value]:", &value)
	}
}
